package br.com.jvet.util.testes;

import java.util.Properties;

import javax.ejb.embeddable.EJBContainer;
import javax.naming.NamingException;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import br.com.jvet.entidade.TipoAnimal;
import br.com.jvet.persistencia.TipoAnimalDAO;

public class TipoAnimalTesteCRUD {

	TipoAnimalDAO dao;

	private static EJBContainer container;

	@BeforeClass
	public static void setUpContainer() throws Exception {
		Properties props = new Properties();
		props.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
		props.put("hibernate.hbm2ddl.auto", "update");

		container = EJBContainer.createEJBContainer(props);
	}

	@Before
	public void setUpBeans() throws NamingException {
		dao = (TipoAnimalDAO) container.getContext().lookup(
				"java:global/jvet/TipoAnimalDAO");
	}

	@Test
	public void testeIncluirTipoAnimal() {
		TipoAnimal tipo = new TipoAnimal();
		tipo.setDescricao("teste animal");

		dao.incluir(tipo);

	}

}
